<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News extends CI_Controller {
    function News() {
        parent::__construct();
		
        $this->load->helper('html');
        $this->load->helper('url');
        $this->load->helper('form');
    }
	
    public function index()
    {
        $this->load->model('News_model');

        $data['make'] = $this->db->get('psacar_make');
        $data['news_latest_list'] = $this->News_model->getNewsListByCategory(1);
        $data['gas_price'] = $this->News_model->getGasPrice();
        $data['newslist'] = $this->News_model->getNewsListByCategory(3);
        //echo $data['newslist']->num_rows();

        $this->load->view('header');
        $this->load->view('news', $data);
        $this->load->view('footer');
    }

    public function detail()
    {
        $news_id = (int)($this->uri->segment(3, 0));
        $this->load->model('News_model');
        $data['make'] = $this->db->get('psacar_make');
        $data['newslist'] = $this->News_model->getNewsListById($news_id);

        $this->load->view('header');
        $this->load->view('templates/news/news_detail',$data);	
        $this->load->view('footer');
    }
}